$(function(){

    //大图Modal
    if(document.getElementById('largeImgModal')){
        var largeImg = new Vue({
            el:"#largeImgModal",
            data:{
                imgUrl : "",
                index: "",
                imgIndex:"",
            },
            methods:{
                nextImg:function(){
                    this.imgUrl = "";
                    var count = blogInfo.blogBlock[this.index].largeUrls.length;

                    if(parseInt(this.imgIndex)+1 >= count){
                        this.imgIndex = 0;
                    }else{
                        this.imgIndex ++;
                    }
                    this.imgUrl = blogInfo.blogBlock[this.index].largeUrls[this.imgIndex];
                },
                prevImg:function(){
                    this.imgUrl = "";
                    var count = blogInfo.blogBlock[this.index].largeUrls.length;
                    if(parseInt(this.imgIndex)- 1 < 0){
                        this.imgIndex = count-1;
                    }else{
                        this.imgIndex --;
                    }
                    this.imgUrl = blogInfo.blogBlock[this.index].largeUrls[this.imgIndex];
                },
                btnIn:function(type){
                    switch(parseInt(type)){
                        case 0:
                            $('#largeImgModal .right-btn img').attr('src','image/largeRightActive.png');
                            break;
                        case 1:
                            $('#largeImgModal .left-btn img').attr('src','image/largeLeftActive.png');
                            break;
                        case 2:
                            $('#largeImgModal .close-btn img').attr('src','image/largeCloseActive.png');
                            break;
                    }
                },
                btnOut: function(type){
                    switch(parseInt(type)){
                        case 0:
                            $('#largeImgModal .right-btn img').attr('src','image/largeRight.png');
                            break;
                        case 1:
                            $('#largeImgModal .left-btn img').attr('src','image/largeLeft.png');
                            break;
                        case 2:
                            $('#largeImgModal .close-btn img').attr('src','image/largeClose.png');
                            break;
                    }
                }
            },

        });
    }

    // 资讯导航信息
    if(document.getElementById('information-nav')){
        var h = new Vue({
            el:'#information-nav',
            data:{
                currType: 1, // 1:24H资讯  4：精选资讯   2: 微博   3: Twitter  5: 技术资讯
                searchContent: "",  //搜索框内容
                blockList:[
                    {name:'ETH',},
                    {name:'EOS',},
                    {name:'XRR',},
                    {name:'LTC',},
                    {name:'OKB',},
                    {name:'ICX',},
                ],
                //个人中心 我的关注人物头像
                follower:[],
            },
            watch:{
                searchContent:function(newVal,oldVal){
                    if(newVal){
                        $('.filtrate-btn').removeClass('btn-active');
                    }
                }
            },
            methods:{
                //头像左右移动
                blockSilder: function(sign,$event){
                    var groupWidth = $('#information-nav .item-group').outerWidth(true);
                    var boxWidth = $('#information-nav .item-box').outerWidth(true);
                    var boxLeft = $('#information-nav .item-box').css('left');
                    if(sign == 'next'){
                        var left = parseFloat(boxLeft) - groupWidth;
                        if(Math.abs(left) <= boxWidth){
                            $('#information-nav .item-box').animate({left: left},400);
                        }
                    }else{
                        var left = parseFloat(boxLeft) + groupWidth;
                        if(left <=0){
                            $('#information-nav .item-box').animate({left: left},400);
                        }
                    }
                },
                //点击头像调用 个人主页
                goPersonalMain: function(event){
                    var type =  $('#information-list .nav-active').attr('value');
                    alert(type);
                    var id = event.currentTarget.getAttribute('value');
                    // location.href="personalMain.html?id="+id;
                    window.open("personalMain.html?id="+id+'&type='+type);
                },
                //搜索按钮
                toSearch: function(event){
                    var searchContent;
                    if(event.currentTarget.type == 'text'){
                        // searchContent =  event.currentTarget.value;
                        searchContent = this.searchContent;
                    }else{
                        // $('.filtrate-input').val('');
                        searchContent = event.currentTarget.getAttribute('value');
                        // searchContent = this.searchContent;
                        if(searchContent==undefined || searchContent == null ){
                            searchContent = $(event.currentTarget).prev().val();
                        }else{
                            this.searchContent = "";
                            $('.filtrate-btn').removeClass('btn-active');
                            $(event.currentTarget).addClass('btn-active');
                        }
                    }
                    if(searchContent =='' || searchContent == null ||  searchContent== undefined){
                        $('.filtrate-input').focus();
                    }else{
                        //设置所有的keyword为搜索内容
                        quickInfo.keyword = siftInfo.keyword= blogInfo.keyword= twitterInfo.keyword= skillInfo.keyword= (searchContent == 'ALL' ? "" : searchContent);
                        quickInfo.currPage = siftInfo.currPage= blogInfo.currPage= twitterInfo.currPage= skillInfo.currPage= 1;
                        quickInfo.pageSize = siftInfo.pageSize= blogInfo.pageSize= twitterInfo.pageSize= skillInfo.pageSize= 10;
                        quickInfo.quickBlock = {};
                        siftInfo.siftBlock= [];
                        blogInfo.blogBlock= [];
                        twitterInfo.twitterBlock= [];
                        skillInfo.skillBlock= [];
                        //获取当前页面类型  this.currType

                        $('.noData').addClass('hidden');
                        $('.loadData').removeClass('hidden');
                        switch(parseInt(this.currType)){
                            case 1:  //24h快讯
                                //获取动态资讯
                                var data = {
                                    infoType:'1' ,
                                    pageSize:quickInfo.pageSize,
                                    pageNum:quickInfo.currPage,
                                    keyword:quickInfo.keyword,
                                    element: quickInfo,
                                };
                                //判断是否为全局搜索
                                var args = getUrlParams();
                                if(args.searchType  && args.searchType == 'all'){
                                    getSearchList(data);
                                }else{
                                    getQuikeList(data);
                                }

                                break;
                            case 4:  //精选资讯
                                //获取技术分析
                                var data ={
                                    infoType: '4', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                                    keyword	: siftInfo.keyword, //关键字	否	100	String	查询关键字
                                    pageSize:siftInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                    pageNum	: siftInfo.currPage, //第几页	否	9	Number	默认1
                                    element: siftInfo,
                                };
                                //判断是否为全局搜索
                                var args = getUrlParams();
                                if(args.searchType  && args.searchType == 'all'){
                                    getSearchList(data);
                                }else{
                                    getArticlesList(data);
                                }
                                break;
                            case 2:  //微博
                                //获取动态资讯
                                var data ={
                                    infoType: '2', //	资讯类型	是	2	Number	2 微博 3twitter
                                    keyword	: blogInfo.keyword, //关键字	否	100	String	查询关键字
                                    pageSize:blogInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                    pageNum	: blogInfo.currPage, //第几页	否	9	Number	默认1
                                    element: blogInfo,
                                };
                                //判断是否为全局搜索
                                var args = getUrlParams();
                                if(args.searchType  && args.searchType == 'all'){
                                    getSearchList(data);
                                }else{
                                    getDynamicList(data);
                                }

                                break;
                            case 3:  //twitter
                                //获取动态资讯
                                var data ={
                                    infoType: '3', //	资讯类型	是	2	Number	2 微博 3twitter
                                    keyword	:twitterInfo.keyword, //关键字	否	100	String	查询关键字
                                    pageSize:twitterInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                    pageNum	: twitterInfo.currPage, //第几页	否	9	Number	默认1
                                    element: twitterInfo,
                                };
                                //判断是否为全局搜索
                                var args = getUrlParams();
                                if(args.searchType  && args.searchType == 'all'){
                                    getSearchList(data);
                                }else{
                                    getDynamicList(data);
                                }

                                break;
                            case 5:  //技术分析
                                //获取技术分析
                                var data ={
                                    infoType: '5', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                                    keyword	: skillInfo.keyword, //关键字	否	100	String	查询关键字
                                    pageSize:skillInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                    pageNum	: skillInfo.currPage, //第几页	否	9	Number	默认1
                                    element: skillInfo,
                                };
                                //判断是否为全局搜索
                                var args = getUrlParams();
                                if(args.searchType  && args.searchType == 'all'){
                                    getSearchList(data);
                                }else{
                                    getArticlesList(data);
                                }

                                break;
                            case 6:  //货币列表
                                // currencyList.runCurrencyAPI();
                                break;
                        }
                    }
                },
                //导航栏转换
                changeNews: function(type,event,showRight){
                    //type 标签类型     event 事件对象     showRight 是否动态显示右侧列表
                    //导航颜色
                    $('.news-nav').removeClass('nav-active');
                    $(event.currentTarget).addClass('nav-active');
                    //右侧栏目显示
                    $('#news-information .box').removeClass('hidden');
                    //显示内容模块
                    type = parseInt(type);
                    $('.news-box').addClass('hidden');
                    $('.noData').addClass('hidden');
                    $('.loadData').removeClass('hidden');
                    this.currType = type;
                    quickInfo.currPage = siftInfo.currPage= blogInfo.currPage= twitterInfo.currPage= skillInfo.currPage= 1;
                    quickInfo.pageSize = siftInfo.pageSize= blogInfo.pageSize= twitterInfo.pageSize= skillInfo.pageSize= 10;
                    quickInfo.quickBlock = {};
                    siftInfo.siftBlock= [];
                    blogInfo.blogBlock= [];
                    twitterInfo.twitterBlock= [];
                    skillInfo.skillBlock= [];
                    switch(type){
                        case 1:  //24h快讯
                            //quickInfo  siftInfo twitterInfo  blogInfo  skillInfo
                            cancelLoad([siftInfo.loadData,twitterInfo.loadData,blogInfo.loadData,skillInfo.loadData]);
                            addLoad(quickInfo.loadData);
                            $('#quick-information').removeClass('hidden');
                            //获取动态资讯
                            var data = {
                                infoType:'1' ,
                                pageSize:quickInfo.pageSize,
                                pageNum:quickInfo.currPage,
                                keyword:quickInfo.keyword,
                                element: quickInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                $('#news-information .notice-box').removeClass('hidden');
                                getQuikeList(data);
                            }
                            break;
                        case 4:  //精选资讯
                            if(document.getElementById('quick-information')){
                                cancelLoad([quickInfo.loadData,twitterInfo.loadData,blogInfo.loadData,skillInfo.loadData]);
                            }else{
                                cancelLoad([twitterInfo.loadData,blogInfo.loadData,skillInfo.loadData]);
                            }
                            addLoad(siftInfo.loadData);
                            $('#sift-information').removeClass('hidden');
                            //获取技术分析
                            var data ={
                                infoType: '4', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                                keyword	: siftInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:siftInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: siftInfo.currPage, //第几页	否	9	Number	默认1
                                element: siftInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                $('#news-information .notice-box').addClass('hidden');
                                getArticlesList(data);
                            }

                            break;
                        case 2:  //微博
                            if(document.getElementById('quick-information')){
                                cancelLoad([siftInfo.loadData,quickInfo.loadData,twitterInfo.loadData,skillInfo.loadData]);
                            }else{
                                cancelLoad([siftInfo.loadData,twitterInfo.loadData,skillInfo.loadData]);
                            }
                            // cancelLoad([siftInfo.loadData,quickInfo.loadData,twitterInfo.loadData,skillInfo.loadData]);
                            addLoad(blogInfo.loadData);

                            $('#blog-information').removeClass('hidden');

                            //获取动态资讯
                            var data ={
                                infoType: '2', //	资讯类型	是	2	Number	2 微博 3twitter
                                keyword	: blogInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:blogInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: blogInfo.currPage, //第几页	否	9	Number	默认1
                                element: blogInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                $('#news-information .notice-box').addClass('hidden');
                                getDynamicList(data);
                            }

                            break;
                        case 3:  //twitter
                            if(document.getElementById('quick-information')){
                                cancelLoad([siftInfo.loadData,blogInfo.loadData,quickInfo.loadData,skillInfo.loadData]);
                            }else{
                                cancelLoad([siftInfo.loadData,blogInfo.loadData,skillInfo.loadData]);
                            }

                            addLoad(twitterInfo.loadData);
                            $('#twitter-information').removeClass('hidden');

                            //获取动态资讯
                            var data ={
                                infoType: '3', //	资讯类型	是	2	Number	2 微博 3twitter
                                keyword	:twitterInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:twitterInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: twitterInfo.currPage, //第几页	否	9	Number	默认1
                                element: twitterInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                $('#news-information .notice-box').addClass('hidden');
                                getDynamicList(data);
                            }

                            break;
                        case 5:  //技术分析
                            if(document.getElementById('quick-information')){
                                cancelLoad([siftInfo.loadData,twitterInfo.loadData,blogInfo.loadData,quickInfo.loadData]);
                            }else{
                                cancelLoad([siftInfo.loadData,twitterInfo.loadData,blogInfo.loadData,]);
                            }

                            addLoad(skillInfo.loadData);
                            $('#skill-information').removeClass('hidden');

                            //获取技术分析
                            var data ={
                                infoType: '5', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                                keyword	: skillInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:skillInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: skillInfo.currPage, //第几页	否	9	Number	默认1
                                element: skillInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                $('#news-information .notice-box').addClass('hidden');
                                getArticlesList(data);
                            }

                            break;
                        case 6:  //货币列表
                            if(document.getElementById('quick-information')){
                                cancelLoad([siftInfo.loadData,twitterInfo.loadData,blogInfo.loadData,quickInfo.loadData,skillInfo.loadData]);
                            }else{
                                cancelLoad([siftInfo.loadData,twitterInfo.loadData,blogInfo.loadData,skillInfo.loadData]);
                            }

                            $('#currency-list').removeClass('hidden');

                            currencyList.runCurrencyAPI();
                            break;
                    }
                },
            },
            mounted: function(){
                this.$nextTick(function(){
                    //设置头像左右移动头像box宽度
                    var itemWidth = $('#information-nav .item-info').eq(0).outerWidth(true); //获取每个item宽度
                    $('#information-nav .item-box').eq(0).width((parseFloat(itemWidth)+60.0)*$('#information-nav .item-info').length);

                    //判断当前用户状态，登录 | 未登录
                    if(isLogin()){
                        $('.attention-box .no-login').addClass('hidden');
                        $('.attention-box .news-nav-num').removeClass('hidden');
                        $('.attention-box .msg-list').removeClass('hidden');
                        $('.attention-box .information-box').removeClass('hidden');

                        $('.my-phone, .my-reg-time').removeClass('hidden');
                        $('.my-status, .my-login').addClass('hidden');

                        // $('#information-nav').css({'min-height':184});
                    }else{
                        $('.attention-box .no-login').removeClass('hidden');
                        $('.attention-box .news-nav-num').addClass('hidden');
                        $('.attention-box .msg-list').addClass('hidden');
                        $('.attention-box .information-box').addClass('hidden');

                        //个人信息
                        $('.my-phone, .my-reg-time').addClass('hidden');
                        $('.my-status, .my-login').removeClass('hidden');

                    }
                });
            },
        });
    }

    //24H快讯
    if(document.getElementById('quick-information')){
        var quickInfo = new Vue({
            el: '#quick-information',
            data:{
                totalNum:0,
                currPage: 1,
                pageSize: 10,
                keyword: getUrlParams().content ? decodeURI(getUrlParams().content) : "",
                //24H资讯
                quickBlock: { },
            },
            components:{
                'quick-content': quickComponent,
            },
            methods:{
                loadData:quickLoadData,
            },
            mounted:function(){
                this.$nextTick(function(){
                    cancelLoad([quickInfo.loadData,siftInfo.loadData,twitterInfo.loadData,blogInfo.loadData,skillInfo.loadData]);
                    addLoad(this.loadData);

                    //获取动态资讯
                    var data = {
                        // infoType:'1' ,
                        pageSize:this.pageSize,
                        pageNum:this.currPage,
                        keyword:this.keyword,
                        infoType:1,
                        element: this,
                    };
                    //判断是否为全局搜索
                    var args = getUrlParams();
                    if(args.searchType  && args.searchType == 'all'){
                        getSearchList(data);
                    }else{
                        getQuikeList(data);
                    }
                });
            },
        });
    }


    //精选资讯
    if(document.getElementById('sift-information')){
        var siftInfo = new Vue({
            el: '#sift-information',
            data:{
                totalNum:0,
                currPage: 1,
                pageSize: 10,
                keyword: getUrlParams().content ? decodeURI(getUrlParams().content) : "",
                siftBlock: [],
            },
            components:{
                'sift-content': siftComponent,
            },
            methods:{
                //加载数据
                loadData: siftLoadData,
            },
            mounted:function(){
                this.$nextTick(function(){
                });
            }
        });
    }


    //twitter
    if(document.getElementById('twitter-information')){
        var twitterInfo = new Vue({
            el: '#twitter-information',
            data:{
                totalNum:0,
                currPage: 1,
                pageSize:10,
                keyword:getUrlParams().content ? decodeURI(getUrlParams().content) : "",
                twitterBlock: [],
            },
            methods:{
                loadData:twitterLoadData,
            },
            components:{
                'twitter-content': twitterComponent,
            },
            mounted:function(){
                this.$nextTick(function(){
                });
            }
        });
    }


    //微博
    if(document.getElementById('blog-information')){
        var blogInfo = new Vue({
            el: '#blog-information',
            data:{
                totalNum:0,
                currPage: 1,
                pageSize: 10,
                keyword:getUrlParams().content ? decodeURI(getUrlParams().content) : "",
                largeImg: largeImg, //记录大图对象
                blogBlock: [ ],
            },
            methods:{
                //滚动加载
                loadData:blogLoadData,
            },
            components:{
                'blog-content': blogComponent,
            },
            mounted:function(){
                this.$nextTick(function(){
                });
            }
        });
    }


    //技术分析
    if(document.getElementById('skill-information')){
        var skillInfo = new Vue({
            el: '#skill-information',
            data:{
                totalNum:0,
                currPage: 1,
                pageSize: 10,
                keyword:getUrlParams().content ? decodeURI(getUrlParams().content) : "",
                skillBlock: [],
            },
            components:{
                'skill-content': skillComponent,
            },
            methods:{
                loadData: skillLoadData,
            },
            mounted:function(){
                this.$nextTick(function(){
                });

            },
        });
    }

    //币种
    if(document.getElementById('currency-list')){
        var currencyList = new Vue({
            el:'#currency-list',
            data:{
                //货币列表
                market:{
                    totalNum: 1, //总页码
                    currArea: [], //当前显示的页码LIST，最多9个
                    maxPage: 9, //页面显示最大页码数
                    currPage: 1, //当前页码
                    conceptId: "", //概念ID
                    sortType: "", //排序类型
                    sortWord:"", //排序字段
                    pageSize:10, //页面行数
                    // pageNum: 1, //当前页码
                    keyword: getUrlParams().content ? decodeURI(getUrlParams().content) : "", //关键字
                    list:[],
                }
            },
            mounted:function(){
                this.$nextTick(function(){
                    //设置页面1
                    // this.setCurrPage('market'); //默认货币列表
                    if(getUrlParams().id){
                        this.market.conceptId = getUrlParams().id;
                    }
                });
            },
            methods:{
                //获得当前是自选还是货币列表
                getCurrType: function(){
                    return '0';
                },
                //跳转货币详细页
                goCurrencyProfile: function(event){
                    var id = event.currentTarget.parentNode.getAttribute('value');
                    window.open( 'currencyProfile.html?id='+id);
                },
                //TAB自选
                myFocus: function(){
                    //查询自选
                    var data = {
                        sortType: this.optional.sortType, //	排序类型	否	1	String	0 升序 1 降序
                        sortWord: this.optional.sortWord, //	排序字段	否	20	String	传入对应字段名即可
                        element: currencyList,
                        tabType: 'optional'
                    };
                    getCoinFocus(data);
                },
                //改变排序
                changeSort: function(event){
                    var currList = this.getCurrType()=='0' ? 'market': 'optional' ;  // 0 货币列表   1 自选
                    var sortWord = event.currentTarget.getAttribute('type');  //按什么字段排序
                    var sortType = event.currentTarget.getAttribute('value'); //降序1 升序 0

                    this[currList].sortWord = sortWord;
                    this[currList].pageNum = 1;
                    if(sortType == '1'){
                        //降序排列
                        $('.sort-img').attr({value:1,src:'image/paixu1.png'});
                        this[currList].sortType = 0;
                        event.currentTarget.setAttribute('value','0');
                        event.currentTarget.setAttribute('src','image/paixu2.png');
                    }else{
                        //升序排列
                        $('.sort-img').attr({value:1,src:'image/paixu1.png'});
                        this[currList].sortType = 1;
                        event.currentTarget.setAttribute('value','1');
                        event.currentTarget.setAttribute('src','image/paixu1.png');
                    }
                    this.runCurrencyAPI();
                },
                //走势图
                drawFlow: function(id,data,date,min,max){
                    // 走势图
                    var myFlow = echarts.init(document.getElementById(id));

                    var flowOption = {
                        grid: { //内部填充距离
                            left: '2%',
                            right: '2%',
                            top:'2%',
                            bottom: '2%',
                            containLabel: true
                        },
                        xAxis: {
                            type: 'category',
                            boundaryGap: false,
                            axisLine:{
                                show:false,
                            },
                            axisTick:{  //刻度线
                                show:false,
                            },
                        },
                        yAxis: {
                            type: 'value',
                            min: min,
                            max: max,
                            boundaryGap: false,
                            axisLine:{
                                show:false,
                            },
                            axisTick:{  //刻度线
                                show:false,
                            },
                            axisLabel:{
                                show:false,
                            },
                            splitLine:{
                                show:false,
                            }
                        },
                        visualMap: {
                            show: false,
                            // type: 'piecewise',
                            // seriesIndex:1,//控制series 对应的区域
                            // dimension: 1,
                            // yAxisIndex: 1,
                            pieces:[ {
                                lte: 0,
                                gt:-100,
                                color: "rgba(253, 120, 137, 1)",
                            }],
                            outOfRange: {
                                color: 'rgba(97, 217, 175, 1)',
                            },
                            backgroundColor:"red",
                        },

                        series: [{
                            smooth:true, //折线圆弧度
                            symbol: "none",//去掉折线圆点

                            sampling: 'average', //数据多余像素点时的显示
                            // data: [-1.1,-3.0, 4, 2, 4, -2.2, 1, 1.6, 3.4],
                            data: data,
                            type: 'line',
                            areaStyle: {
                                color:'rgba(97, 217, 175, 0.3)',
                                origin: 'auto',
                            },
                        },]
                    };


                    // 使用刚指定的配置项和数据显示图表。
                    myFlow.setOption(flowOption,true);
                },
                //搜索查询
                toSearch: function(event){
                    if(event.currentTarget.type == 'text'){
                        var str =  event.currentTarget.value; //搜索内容
                    }else{
                        var str = $(event.currentTarget).prev().val();
                    }

                    if(str =='' || str == null || str == undefined){
                        $('.filtrate-input').focus();
                    }else{
                        //设置对象的概念ID
                        this.market.conceptId =  this.optional.conceptId = "";
                        this.market.currPage =  this.optional.currPage = 1;
                        this.market.sortType =  this.optional.sortType = 1;
                        this.market.sortWord =  this.optional.sortWord = "";
                        this.market.keyWord =  this.optional.keyWord = str;
                        this.runCurrencyAPI();
                    }
                },
                //根据当前页设置 显示页码行
                setCurrPage:function(currList){
                    this[currList].currArea = []; //清空当前页码区
                    //判断页码总数是否小于 页码最大值
                    if(this[currList].totalNum <= this[currList].maxPage){
                        for(var m=0; m<this[currList].totalNum; m++){
                            Vue.set(this[currList].currArea,this[currList].currArea.length, m+1);
                        }
                        this.$nextTick(function(){
                            $('.page-num-btn').eq(this[currList].currPage-1).addClass('page-active');
                        });

                    }else{
                        var min = parseInt(this[currList].currPage - Math.floor(this[currList].maxPage /2));
                        var max = parseInt(this[currList].currPage + Math.floor(this[currList].maxPage /2));
                        if( min >1 &&  max <= this[currList].totalNum ){
                            for(var k=0; k< this[currList].maxPage; k++){
                                Vue.set(this[currList].currArea,this[currList].currArea.length,min+k);
                            }
                            this.$nextTick(function(){
                                $('.page-num-btn').removeClass('page-active').eq(Math.floor(this[currList].maxPage /2)).addClass('page-active');
                            });

                        }else{
                            $('.page-next').removeClass('disabled');
                            $('.page-num-btn').removeClass('page-active');
                            //判断在前几页还是后几页
                            if(min <=1 ){
                                // this[currList].currArea = [];
                                for(var m=0; m<this[currList].maxPage; m++){
                                    Vue.set(this[currList].currArea,this[currList].currArea.length, m+1);
                                }
                                this.$nextTick(function(){
                                    $('.page-num-btn').eq(parseInt(this[currList].currPage)-1).addClass('page-active');
                                });

                            }else{
                                var startPage = this[currList].totalNum - this[currList].maxPage+1;
                                for(var m=0;  m<this[currList].maxPage ; m++){
                                    Vue.set(this[currList].currArea,this[currList].currArea.length, startPage++);
                                }
                                this.$nextTick(function(){
                                    $('.page-num-btn').eq(this[currList].maxPage-(this[currList].totalNum - this[currList].currPage)-1).addClass('page-active');
                                });

                            }
                        }
                    }
                },
                //数字翻页
                toPage:function(currList,event){
                    var page = event.currentTarget;
                    var value = parseInt(page.value);  //点击的当前页码
                    switch(value){
                        case  -1:  //往前翻页
                            if(this[currList].currPage - 1 > 0 ){
                                this[currList].currPage--; //设置当前页码减 1
                            }else{
                                $(page).addClass('disabled');  //设置禁用标志
                            }
                            break;
                        case 0 :  //向后一页
                            if(this[currList].currPage + 1 <= this[currList].totalNum ){
                                this[currList].currPage++; //设置当前页码加 1
                            }else{
                                $(page).addClass('disabled'); //设置禁用标志
                            }
                            break;
                        default:
                            this[currList].currPage = value; //设置当前页码
                    }
                    this.runCurrencyAPI();

                },
                //跳转翻页
                jumpPage: function(currList,event){
                    var inPage = parseInt(event.currentTarget.value) ;
                    if(inPage >0 && inPage <= this[currList].totalNum ){
                        this[currList].currPage  = inPage; //设置当前页码
                        this.runCurrencyAPI();
                    }else{
                        alert('页码错误');
                    }
                },
                //设置每页行数
                setPageNum:function(currList,event){
                    this[currList].pageSize = event.currentTarget.value;
                    this.runCurrencyAPI();
                },
                //设置自选
                setFavorite:function(name,event){
                    if(isLogin()){
                        var id = event.currentTarget.parentNode.parentNode.getAttribute('value');
                        var followId = event.currentTarget.parentNode.parentNode.getAttribute('followid');
                        var index = event.currentTarget.parentNode.getAttribute('value');
                        var data = {};
                        if(this[name].list[index].isFavorite){
                            //取消自选
                            data = {followId: followId,element:this.market,index:index};
                            removeSelfChange(data);
                        }else{
                            //添加自选
                            data = {coinId: id , focusType:0,element:this.market,index:index};
                            addSelfChange(data);
                        }
                    }else{
                        location.href = 'login.html';
                    }
                },
                //运行哪个接口程序
                runCurrencyAPI:function(){
                    switch(parseInt(this.getCurrType())){
                        case 0 :   //货币列表
                            //查询货币列表

                            var data = {
                                conceptId:this.market.conceptId, //概念ID
                                sortType:this.market.sortType,  // 排序类型
                                sortWord:this.market.sortWord, //排序字段
                                pageSize:this.market.pageSize,  //每页显示条目
                                pageNum:this.market.currPage,  //当前页
                                keyword:searchBox.searchContent,  //搜索关键字
                                element: this,  //当前对象
                                tabType: 'market',
                            };
                            getCoins(data);

                            break;
                        case 1:    //自选
                            //查询自选
                            var data = {
                                sortType: this.optional.sortType, //	排序类型	否	1	String	0 升序 1 降序
                                sortWord: this.optional.sortWord, //	排序字段	否	20	String	传入对应字段名即可
                                element: this,
                                tabType : 'optional',
                            };
                            getCoinFocus(data);
                            break;
                        default:
                            alert('严重错误');
                    }
                }
            },
        });
    }

    if(document.getElementById('search-box')){
        // 搜索框
        var searchBox = new Vue({
            el:"#search-box",
            data:{
                searchContent: "", //搜索内容
            },
            methods:{
                search: function(){
                    this.searchContent = this.searchContent.toUpperCase()
                    quickInfo.currPage = siftInfo.currPage= skillInfo.currPage = blogInfo.currPage = twitterInfo.currPage = currencyList.market.currPage = 1;
                    quickInfo.keyword = siftInfo.keyword= skillInfo.keyword = blogInfo.keyword = twitterInfo.keyword = currencyList.market.keyword = this.searchContent;

                    var type = parseInt($('#information-list').find('.nav-active').attr('value'));
                    switch (type) {
                        case 1: //24H快讯
                            quickInfo.quickBlock = {};
                            var data = {
                                infoType:'1' ,
                                pageSize:quickInfo.pageSize,
                                pageNum:quickInfo.currPage,
                                keyword:quickInfo.keyword,
                                element: quickInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                getQuikeList(data);
                            }
                            break;
                        case 2: //微博
                            blogInfo.blogBlock = [];
                            var data ={
                                infoType: '2', //	资讯类型	是	2	Number	2 微博 3 twitter
                                keyword	: blogInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:blogInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: blogInfo.currPage, //第几页	否	9	Number	默认1
                                element: blogInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                getDynamicList(data);
                            }
                            break;
                        case 3: //twitter
                            var data ={
                                infoType: '3', //	资讯类型	是	2	Number	2 微博 3 twitter
                                keyword	: twitterInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:twitterInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: twitterInfo.currPage, //第几页	否	9	Number	默认1
                                element: twitterInfo,
                            };
                            getDynamicList(data);
                            break;
                        case 4:
                            siftInfo.siftBlock = [];
                            var data ={
                                infoType: '4', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                                keyword	: siftInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:siftInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: siftInfo.currPage, //第几页	否	9	Number	默认1
                                element: siftInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                getArticlesList(data);
                            }
                            break;
                        case 5:
                            skillInfo.skillBlock = [];
                            var data ={
                                infoType: '5', //	资讯类型	是	2	Number	4 精选资讯 5 技术分析
                                keyword	: skillInfo.keyword, //关键字	否	100	String	查询关键字
                                pageSize:skillInfo.pageSize, //	每页条数	否	9	Number	默认10，最大50
                                pageNum	: skillInfo.currPage, //第几页	否	9	Number	默认1
                                element: skillInfo,
                            };
                            //判断是否为全局搜索
                            var args = getUrlParams();
                            if(args.searchType  && args.searchType == 'all'){
                                getSearchList(data);
                            }else{
                                getArticlesList(data);
                            }
                            break;
                        case 6:
                            currencyList.market.list = [];
                            //查询货币列表
                            var data = {
                                conceptId:currencyList.market.conceptId, //概念ID
                                sortType:currencyList.market.sortType,  // 排序类型
                                sortWord:currencyList.market.sortWord, //排序字段
                                pageSize:currencyList.market.pageSize,  //每页显示条目
                                pageNum:currencyList.market.currPage,  //当前页
                                keyword:currencyList.market.keyword,  //搜索关键字
                                element: currencyList,  //当前对象
                                tabType: 'market',
                            };
                            getCoins(data);
                            break;
                    }
                }
            },
            mounted:function(){
                this.$nextTick(function(){
                    var args = getUrlParams();
                    if(args.content){
                        searchBox.searchContent =  decodeURI(args.content).toUpperCase();
                    }

                });
            },
        });
    }




});